package com.wbcs.jbsf.action;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.wbcs.config.component.IComponentConfigBean;
import com.wbcs.jbsf.dao.IDataModal;
import com.wbcs.jbsf.dao.JBSFDaoTemplate;
import com.wbcs.system.ReportRequest;
import com.wbcs.system.serveraction.IServerAction;
import com.wbcs.util.Consts;

public class CreateTopNumAction implements IServerAction
{
    public String executeSeverAction(ReportRequest rrequest,IComponentConfigBean ccbean,List<Map<String,String>> lstData,
            Map<String,String> mCustomizedData)
    {
        // 在lstData中按照siteid进行查询，并返回查询结果为json
        JBSFDaoTemplate jdaoTemplate = new JBSFDaoTemplate(false);
        StringBuffer sql = new StringBuffer("select SEQ_TOPNUM.Nextval from dual");
        
        String topnum = "";
		try {
			topnum = jdaoTemplate.<String>select(sql.toString(),new IDataModal<String>()
			{
			    public String loadDatas(ResultSet rs,int ccount,ResultSetMetaData rmd,String dataModal)
			            throws SQLException
			    {
			        while(rs.next()){
			            dataModal = rs.getString(1);
			        }
			        return dataModal;
			    }
			});
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        rrequest.getWResponse().setStatecode(Consts.STATECODE_NONREFRESHPAGE);
        return topnum;
    }

    public String executeServerAction(HttpServletRequest request,HttpServletResponse response,List<Map<String,String>> lstData)
    {
        // TODO Auto-generated method stub
        return null;
    }

}

